home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / MATHS / RLAB / RLAB125.ZIP / !RLaB / toolbox / mret < prev    next >
Text File  |  1994-02-21  |  1KB  |  49 lines

  1. //-------------------------------------------------------------------//
  2.  
  3. //  Syntax:    mret ( LIST, a, b, c, d, e, f, g, h )
  4.  
  5. //  Description:
  6.  
  7. //  The function mret is provided to allow users to use functions that
  8. //  return multiple arguments in a "MATLAB"-like fashion. Mret stands
  9. //  for Matlab RETurn. Proper usage of mret() is best shown with
  10. //  examples: 
  11.  
  12. //  In MATLAB you might call eig like:
  13.  
  14. //    [v,d] = eig (a);
  15.  
  16. //  Using mret you could:
  17.  
  18. //    mret (eig (a), v="vec", d="val");
  19.  
  20. //  The above example assigns the list members that eig() returns to
  21. //  the variables `v', and `d'. The values of the strings determine
  22. //  the mapping between RLaB list elements, and user variable names.
  23.  
  24. //  The list returned by the 1st argument is destroyed after the
  25. //  assignments are complete.
  26.  
  27. //  If eight return-element mappings are not enough, mret() can easily
  28. //  be expanded.
  29.  
  30. //-------------------------------------------------------------------//
  31.  
  32. mret =  function ( L, a, b, c, d, e, f, g, h )
  33. {
  34.   if (class (L) == "list")
  35.   {
  36.     if (exist (a)) {  a = L.[a]; }
  37.     if (exist (b)) {  b = L.[b]; }
  38.     if (exist (c)) {  c = L.[c]; }
  39.     if (exist (d)) {  d = L.[d]; }
  40.     if (exist (e)) {  e = L.[e]; }
  41.     if (exist (f)) {  f = L.[f]; }
  42.     if (exist (g)) {  g = L.[g]; }
  43.     if (exist (h)) {  h = L.[h]; }
  44.   else
  45.     error ("mret: 1st argument must be a list-object");
  46.   }
  47.   clear (L);
  48. };
  49.